<script setup>
import {reactive} from "vue";
import {Lock, User} from '@element-plus/icons-vue'
// import {login} from "@/net";
import {ref} from "vue";
import router from "@/router";
/*定义数据*/
const formRef = ref()

const form = reactive({
  username: '',
  password: '',
  remember: false
})

const rule = {
  username: [
    {required: true,message:'请输入用户名'}
  ],
  password:[
    {required: true,message:'请输入密码'}
  ]
}

/*函数*/
//用户登录
function userLogin(){
  
  router.push('/main')


  // 登录规则
  // console.log(form.username + ':' + form.password)
  // formRef.value.validate((valid)=>{
  //   if (valid){
  //     login(form.username,form.password,form.remember,()=>router.push('/index'))
  //   }
  // })
}

</script>

<template>
  <div style="width: 100vw;height: 100vh;overflow: hidden;display: flex">
  <div style="flex: 1;background-color: black">
    <el-image style="width: 100%;height: 100%" fit="cover"
        src="https://www.toopic.cn/public/uploads/small/1642749399720164274939972.jpg"/>
  </div>
  <div style="text-align: center;margin: 0 20px">
    <div style="margin-top: 150px">
      <div style="font-size: 25px;font-weight: bold">登录</div>
      <div style="font-size: 14px;color: grey">在进入系统之前，请输入用户名和密码进行登录</div>
    </div>
    <div style="margin-top: 50px">
      <el-form :model="form" :rules="rule" ref="formRef">
        <el-form-item prop="username">
          <el-input v-model="form.username" maxlength="20" type="text" placeholder="用户名/邮箱">
            <template #prefix>
              <el-icon><User /></el-icon>
            </template>
          </el-input>
        </el-form-item >
        <el-form-item prop="password">
          <el-input v-model="form.password" type="password" maxlength="20" placeholder="密码">
            <template #prefix>
              <el-icon><Lock /></el-icon>
            </template>
          </el-input>
        </el-form-item>
        <el-row>
          <el-col :span="12" style="text-align: left">
            <el-form-item prop="remember">
              <el-checkbox v-model="form.remember" label="记住我">

              </el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="12" style="text-align: right">
            <el-link @click="router.push('/reset')">忘记密码？</el-link>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div style="margin-top: 40px">
      <el-button style="width: 270px" type="success" plain @click="userLogin">立即登录</el-button>
    </div>
    <el-divider>
      <span style="font-size: 13px;color: grey">没有账号</span>
    </el-divider>
    <div>
      <el-button style="width: 270px" type="warning" plain @click="router.push('/register')">立即注册</el-button>
    </div>
  </div>
  </div>
</template>

<style scoped>

</style>